package com.wxl.asmgradleplugin.myplugin

import org.objectweb.asm.ClassVisitor
import org.objectweb.asm.MethodVisitor

class LogClassVisitor(api: Int, classVisitor: ClassVisitor) : ClassVisitor(api, classVisitor) {

    private var className: String? = null

    override fun visit(
        version: Int,
        access: Int,
        name: String?,
        signature: String?,
        superName: String?,
        interfaces: Array<out String>?
    ) {
        super.visit(version, access, name, signature, superName, interfaces)
        className = name
        println("====== 222 visit class=$name")
    }


    override fun visitMethod(
        access: Int,
        name: String?,
        desc: String?,
        signature: String?,
        exceptions: Array<out String>?
    ): MethodVisitor {
        var methodVisitor = super.visitMethod(access, name, desc, signature, exceptions)
        println("======222 name is $name, desc is $desc")
        methodVisitor = LogMethodVisitor(className, api, methodVisitor, access, name, desc)
        return methodVisitor
    }
}